package com.example.springbolgdemo.pojo.response;

import com.example.springbolgdemo.contstant.Contstants;
import lombok.Data;

@Data
public class Result <T> {
    private int code;
    private String errMsg;
    private T data;

    public static <T>Result success(T data){
        Result result=new Result();
        result.setCode(Contstants.RESULT_SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T>Result fail(T data,String errMsg){
        Result result=new Result();
        result.setCode(Contstants.RESULT_FIAL);
        result.setData(data);
        result.setErrMsg(errMsg);
        return result;
    }

    public static <T>Result fail(String errMsg){
        Result result=new Result();
        result.setCode(Contstants.RESULT_FIAL);
        result.setErrMsg(errMsg);
        return result;
    }


}
